Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Memory

Previous | Chapter Top | Chapter Contents | Next |

Grow-Zone Operations

You can implement a grow-zone function that the Memory Manager calls when it cannot fulfill a memory request. You should use the grow-zone function only as a last resort to free memory when all else fails. For explanations of how grow-zone functions work and an example of a memory-management scheme that uses a grow-zone function, see the discussion of low-memory conditions in the chapter "Introduction to Memory Management" in this book.

The SetGrowZone procedure specifies which function the Memory Manager should use for the current zone. The grow-zone function should call the GZSaveHnd function to receive a handle to a relocatable block that the grow-zone function must not move or purge.

SetGrowZone

To specify a grow-zone function for the current heap zone, pass a pointer to that function to the SetGrowZone procedure. Ordinarily, you call this procedure early in the execution of your application.

If you initialize your own heap zones besides the application and system zones, you can alternatively specify a grow-zone function as a parameter to the InitZone procedure.

PROCEDURE SetGrowZone (growZone: ProcPtr);
growZone
A pointer to the grow-zone function.

DESCRIPTION

The SetGrowZone procedure sets the current heap zone's grow-zone function as designated by the growZone parameter. A NIL parameter value removes any grow-zone function the zone might previously have had.

The Memory Manager calls the grow-zone function only after exhausting all other avenues of satisfying a memory request, including compacting the zone, increasing its size (if it is the original application zone and is not yet at its maximum size), and purging blocks from it.

See "Grow-Zone Functions" for a complete description of a grow-zone function.

ASSEMBLY-LANGUAGE INFORMATION

The registers on entry and exit for SetGrowZone are

Registers on entry

A0

Pointer to new grow-zone function

Registers on exit

D0

Result code

RESULT CODES

noErr

0

No error

GZSaveHnd

Your grow-zone function must call the GZSaveHnd function to obtain a handle to a protected relocatable block that the grow-zone function must not move, purge, or delete.

FUNCTION GZSaveHnd: Handle;

DESCRIPTION

The GZSaveHnd function returns a handle to a relocatable block that the grow-zone function must not move, purge, or delete. It returns NIL if there is no such block. The returned handle is a handle to the block of memory being manipulated by the Memory Manager at the time that the grow-zone function is called.

ASSEMBLY-LANGUAGE INFORMATION

You can find the same handle in the global variable GZRootHnd .


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next